import 'package:flutter/material.dart';
import 'package:xinxuan/common/network_image_util.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/vo/common_vo/common_blindbox_packages_vo.dart';

class SeckillOrderDetailGoodsBody extends StatelessWidget {
  
  final List<CommonBlindBoxPackagesVo> products;
  final String statusStr;
  SeckillOrderDetailGoodsBody({
    required this.products,
    required this.statusStr
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h),
          color: bgWhiteColor,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                '商品信息',
                style: TextStyle(
                  color: textBlackColor,
                  fontSize: 14.sp,
                  fontWeight: FontWeight.bold
                ),
              ),
              Text(
                '$statusStr',
                style: TextStyle(
                  color: mainTextColor,
                  fontSize: 14.sp
                ),
              )
            ],
          ),
        ),
        Column(
          children: products.map((item) {
            return _goodsInfo(item.title!, item.image!, item.price!, item.quantity!);
          }).toList()
        )
      ],
    );
  }

  /// 商品信息
  Widget _goodsInfo(String title, String headImage, String price, int quantity) {
    return Container(
      padding: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 12.h),
      color: bgWhiteColor,
      child: Row(
        children: [
          NetworkImageUtil(
            url: headImage, 
            width: 90.w, 
            height: 90.w,
            borderRadius: 5.w,
          ),
          SizedBox(width: 12.w),
          Expanded(child: Container(
            constraints: BoxConstraints(
              minHeight: 90.w
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Text(
                  title,
                  overflow: TextOverflow.ellipsis,
                  maxLines: 2,
                  style: TextStyle(
                    color: textBlackColor,
                    fontSize: 14.sp
                  ),
                ),
                SizedBox(height: 6.h),
                Row(
                  children: [
                    Expanded(child: Text(
                      '¥$price',
                      style: TextStyle(
                        color: mainTextColor,
                        fontSize: 18.sp,
                        fontWeight: FontWeight.bold
                      )
                    )),
                    Text(
                      'x$quantity',
                      style: TextStyle(
                        color: textSubtitleColor,
                        fontSize: 14.sp,
                        fontWeight: FontWeight.bold
                      )
                    ),
                  ],
                )
              ],
            ),
          ))
        ],
      ),
    );
  }
}